﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace QuTouTiaoAssist.Util
{
    class ChinaUnicomUtil
    {
        public static List<string> GetMobiles()
        {
            string url =
                string.Format("http://num.10010.com/NumApp/NumberCenter/qryNum?callback=jsonp_queryMoreNums&provinceCode=11&cityCode=110&numNet={0}&sortType=1&goodsNet=4&qryType=01&searchCategory=3",
                new Random((int)DateTime.Now.Ticks).Next(0,1) + 185);

            string result = HttpUtil.GetResponseString(url, HttpMethod.GET, null);
            int start = result.IndexOf("{");
            int end = result.LastIndexOf("}");
            result = result.Substring(start, end + 1 - start);

            var type = new
            {
                numArray = new List<string>()
            };

            return JsonConvert.DeserializeAnonymousType(result, type).numArray.FindAll(match => match.Length == 11);
        }
    }
}
